package com.example.canal.conf;

/**
 * @author yzy
 * @date 2020/9/24
 */
public class DataSourceContext {


    /**
     * 将ThreadLocal设置为静态的，可以让当前线程中所有的类都能够共享
     */
    private final static ThreadLocal<String> DATA_SOURCE_POOL = new ThreadLocal<String>();

    public static String getDataSource() {
        return DATA_SOURCE_POOL.get();
    }

    public static void setDataSource() {
        DATA_SOURCE_POOL.set("read");
    }

    public static void removeDataSource() {
        DATA_SOURCE_POOL.remove();
    }

}
